<template>
  <basic-container :btnFlag=true>
    <div class="card-border">
      <card-header :header-data="headerData"></card-header>
      <!-- <div class="step-group">
        <el-steps :active="0">
          <el-step :title="step.title" :icon="step.icon" :class="step.class" v-for="(step,index) in stepList" :key="index"></el-step>
        </el-steps>
      </div> -->
    
      <el-form
        label-width="120px"
        :model="projectForm"
        :rules="projectFormRelease"
        style="padding-right: 30px;"
        ref="projectForm"
      >
        <el-row>
          <el-col :span="24" style="margin-top: 27px;">
            <el-col :span="24">
              <el-form-item class="form-item-release" label="规划名称 :" prop="regName">
                <span>{{regName}}</span>
        <div style="float: right;margin-right: 31px;">
          <el-button type="primary" size="mini" @click.stop="regDetail()">查看规划详情</el-button>
        </div>
              </el-form-item>
            </el-col>
          </el-col>
        </el-row>
        <!--专项规划备案不需要-->
        <el-row>
          <el-col :span="22" style="margin-top: 27px;">
            <el-col :span="20">
              <el-form-item class="form-item-release" label="标题 :" prop="title">
                <el-input v-model="projectForm.title" placeholder="请输入标题"></el-input>
              </el-form-item>
            </el-col>
          </el-col>
        </el-row>
        <el-row style="height:90px"  v-if="!(category == 'B' && planningRank == 'C')">
          <el-col :span="22" style="margin-top: 27px;">
            <el-col :span="20">
              <el-form-item class="form-item-release" label="报送文件 :" prop="files">
                <el-upload
            class="upload-demo"
            action="string"
            :http-request="otherFileUpload"
            :on-preview="otherFileHandlePreview"
            :on-remove="otherFileHandleRemove"
            :auto-upload="true"
            :file-list="defaultOtherFileIds"
          >
            <el-button slot="trigger" size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">请上传附件</div>
          </el-upload>
              </el-form-item>
            </el-col>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="22">
            <el-col :span="20">
              <el-form-item class="form-item-release" :label="openScopeText" prop="openScope">
                <el-select
                  v-model="projectForm.openScope"
                  placeholder="请选择"
                  style="width: 280px;"
                >
                  <el-option
                    v-for="item in publishDIC"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-col>
        </el-row>
      </el-form>

      <el-collapse v-model="activeNames">
        <el-collapse-item name="0">
          <template slot="title">
            <div class="card-header collapse-header">
              <div class="head-title collapse-title">材料清单</div>
            </div>
          </template>
          <avue-crud :data="materialData"
                     :option="materialOption">
            <template slot-scope="scope" slot="menu">
              <div class="menu-title" @click.stop="uploadFiles(scope.row)" v-if="!uploadFlag(scope.row,scope.index)" >
                <i class="iconfont iconview" style="color: #409EFF;"></i>
                <p class="menu-title-text">上传材料</p>
              </div>
              <div class="menu-title" @click.stop="uploadFiles(scope.row)" v-if="uploadFlag(scope.row,scope.index)" >
                <i class="iconfont iconalter" style="color: #ffb424;"></i>
                <p class="menu-title-text">已上传</p>
              </div>
            </template>
          </avue-crud>
        </el-collapse-item>
      </el-collapse>
      <div class="form-submit" v-if="!updateFlag">
        <el-button type="primary" @click.stop="reviewSaveAndSubmit()">提交</el-button>
        <el-button type="info" @click.stop="goBack()">关闭</el-button>
      </div>
      <div class="form-submit" v-if="updateFlag">
        <el-button type="warning" @click.stop="reviewUpdate()">修改</el-button>
        <el-button type="primary" @click.stop="reviewUpdateAndSubmit()">修改并提交</el-button>
        <el-button type="info" @click.stop="goBack()">关闭</el-button>
      </div>
    </div>
    <el-dialog
      title="附件上传"
      :visible.sync="fileDialog['编制说明']"
      width="30%"
      :before-close="handleClose">
      <el-upload
        class="uploadFile"
        ref="upload"
        action="string"
        :http-request="fileUploadRequest"
        :on-preview="fileHandlePreview"
        :on-remove="fileHandleRemove"
        :auto-upload="true"
        :limit="1"
        :on-exceed="tipFileOne"
        :file-list="defaultFileTypeIds['编制说明']"
      >
        <el-button slot="trigger" size="small" type="primary">点击上传</el-button>
      </el-upload>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="fileDialog['编制说明'] = false">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="附件上传"
      :visible.sync="fileDialog['规划文本']"
      width="30%"
      :before-close="handleClose">
      <el-upload
        class="uploadFile"
        ref="upload"
        action="string"
        :http-request="fileUploadRequest"
        :on-preview="fileHandlePreview"
        :on-remove="fileHandleRemove"
        :auto-upload="true"
        :limit="1"
        :on-exceed="tipFileOne"
        :file-list="defaultFileTypeIds['规划文本']"
      >
        <el-button slot="trigger" size="small" type="primary">点击上传</el-button>
      </el-upload>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="fileDialog['规划文本'] = false">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="附件上传"
      :visible.sync="fileDialog['衔接意见']"
      width="30%"
      :before-close="handleClose">
      <el-upload
        class="uploadFile"
        ref="upload"
        action="string"
        :http-request="fileUploadRequest"
        :on-preview="fileHandlePreview"
        :on-remove="fileHandleRemove"
        :auto-upload="true"
        :limit="1"
        :on-exceed="tipFileOne"
        :file-list="defaultFileTypeIds['衔接意见']"
      >
        <el-button slot="trigger" size="small" type="primary">点击上传</el-button>
      </el-upload>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="fileDialog['衔接意见'] = false">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="附件上传"
      :visible.sync="fileDialog['专家评审意见']"
      width="30%"
      :before-close="handleClose">
      <el-upload
        class="uploadFile"
        ref="upload"
        action="string"
        :http-request="fileUploadRequest"
        :on-preview="fileHandlePreview"
        :on-remove="fileHandleRemove"
        :auto-upload="true"
        :limit="1"
        :on-exceed="tipFileOne"
        :file-list="defaultFileTypeIds['专家评审意见']"
      >
        <el-button slot="trigger" size="small" type="primary">点击上传</el-button>
      </el-upload>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="fileDialog['专家评审意见'] = false">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="附件上传"
      :visible.sync="fileDialog['其他附件']"
      width="30%"
      :before-close="handleClose">
      <el-upload
        class="uploadFile"
        ref="upload"
        action="string"
        :http-request="fileUploadRequest"
        :on-preview="fileHandlePreview"
        :on-remove="fileHandleRemove"
        :auto-upload="true"
        :file-list="defaultFileTypeIds['其他附件']"
      >
        <el-button slot="trigger" size="small" type="primary">点击上传</el-button>
      </el-upload>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="fileDialog['其他附件'] = false">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="附件上传"
      :visible.sync="fileDialog['规划文本(部分公开)']"
      width="30%"
      :before-close="handleClose">
      <el-upload
        class="uploadFile"
        ref="upload"
        action="string"
        :http-request="fileUploadRequest"
        :on-preview="fileHandlePreview"
        :on-remove="fileHandleRemove"
        :auto-upload="true"
        :limit="1"
        :on-exceed="tipFileOne"
        :file-list="defaultFileTypeIds['规划文本(部分公开)']"
      >
        <el-button slot="trigger" size="small" type="primary">点击上传</el-button>
      </el-upload>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="fileDialog['规划文本(部分公开)'] = false">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog
      title="规划详情"
      :visible.sync="regDetailDialogFlag"
      width="70%"
      :before-close="regDetailClose">
      <div style="float: right;
                      font-size: 18px;
                      text-align: center;
                      margin-right: 51px;" v-if="pmuc">
        <span>规划编码：</span>
        <span style="display: inline-block">{{pmuc}}</span>
      </div>
      <div class="searchDetail">
        <bostech-detail :detail-data="detailData"></bostech-detail>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="regDetailDialogFlag = false">确 定</el-button>
      </span>
    </el-dialog>
  </basic-container>
</template>

<script>
  import {reviewRules} from "@/const/infoRules";
  import {addSubject} from "@/api/subject";
  import {addReviewRelease,reviewSaveAndSubmit,reviewDetail,reviewUpdate,reviewFile,reviewImg,previewImg,reviewUpdateAndSubmit} from "@/api/review";
  import {resultDetail} from "@/api/planning/result";
  import {getfileinfo,getfileinfopage} from "@/api/system";
  import fileTypeMixin from "@/mixins/fileTypeMixin";
  import getDetailData from "@/mixins/getDetailData";
  import { REVIEW_DIC } from "@/const/dict";
  import reviewList from "@/components/review/reviewList";
  import {materialDataList,fileUploadMaps,stepMap,getStepList} from "@/views/review/const"
  import { mapGetters } from "vuex";
  export default {
    name: "approvalRelease",
    mixins:[fileTypeMixin,getDetailData()],
    components: {
      reviewList
    },
    data(){
      return{
        headerData:{
          title:'材料收集'
        },
        activeNames:["0","1","2"],
        // 规划详情弹窗
        regDetailDialogFlag:false,
        // 规划名称
        regName:'',
        reviewInfsrules:reviewRules,// 表单验证
        projectFormRelease:{
          title: [
            {required: true, message: "请输入标题", trigger: "blur"}
          ],
          openScope: [
            {required: true, message: "请选择拟发布范围", trigger: "blur"}
          ],
        },
        projectForm: {
        },
        openScopeText:'拟发布范围：',
        // 发布方式字典
        publishDIC:REVIEW_DIC.publishDIC,
        // 图件预览弹框imgUrl
        dialogImageUrl: '',
        // 图件预览弹框是否显示
        dialogVisible: false,
        // 修改默认材料Ids
        defaultOtherFileIds:[],
        // 修改默认材料清单Ids
        defaultFileTypeIds:[],
        // 请示件附件Id
        otherFileIds:[],
        // 请示件文件上传配置
        otherFileMap:{
          sucMethod:function (res,params,self) {
            self.otherFileIds.push(Object.assign({id:res.data.data},params.file));
            self.successNotify()
          },
          failMethod:function (res,params,self) {
            self.failNotify()
          }
        },
        fileDialog:{
          '编制说明': false,
          '规划文本':false,
          '衔接意见':false,
          '专家评审意见':false,
          '其他附件':false,
          '规划文本(部分公开)':false
        },
        // 附件类型
        fileType:'',
        // 新增修改标志 true：为修改，false为新增
        updateFlag:false,
        reviewId:'',
        category:'',
        planningRank:'',
        stepList:[],
        stepMap:stepMap,
        materialData:[],
        materialOption: {
          page: false,
          addBtn: false,
          editBtn: false,
          addRowBtn: false,
          indexLabel: "序号",
          index: true,
          indexWidth:70,
          cellBtn: false,
          delBtn: false,
          columnBtn: false,
          refreshBtn: false,
          filterBtn: false,
          searchBtn: false,
          menuWidth:150,
          keyId: "id",
          column: [
            {
              label: "材料名称",
              prop: "name",
              cell: true,
              formatter: function (row, value, label, column) {
                if(row.fileName){
                  value += ' : <a style="color: red;cursor: pointer;" onclick="downloadFile(\''+row.fileId+'\',\''+row.fileName+'\')">'+row.fileName+'</a>'
                }
                if(row.necessity == '必要'){
                  return '<span style="color: red;float: left;margin-top: -2px;margin-right: 2px;">*</span>' +value;
                }
                return value;
              }
            }
          ]
        },
        pmuc:null
      }
    },
    watch:{
      'projectForm.openScope'(val){
        // 如果拟发布范围为部分公开 则
        if(val == '1'){
          if(this.materialData.filter(item => item.name == '规划文本(部分公开)').length<=0){
            this.materialData.push({
              name:'规划文本(部分公开)',
              shape:'电子文件',
              requirement:'',
              necessity:'必要',
              remarks:'',
              hasUpload:true
            })
          }
        }else{
          this.materialData = this.materialData.filter(item => item.name != '规划文本(部分公开)')
        }
      }
    },
    computed: mapGetters([
      "deptInfo"
    ]),
    created(){
      this.projectForm.achievementId = this.$route.params.id;
      this.putTitle();
      this.getDetailData();
      // 修改
      let reviewId = this.$route.query.reviewId;
      if(reviewId){
        this.updateFlag = true;
        this.getDetail(reviewId);
        this.reviewId = reviewId
      }
      let self = this;
      window.downloadFile = self.fileDownload
    },
    methods:{
      putTitle(){
        if(this.$route.query.planningRank=='B'&&this.$route.query.category=='B'){//一般专项
          this.projectForm.title =this.$route.query.orgName + "关于要求联合印发《"+this.$route.query.title+"》的函";
        }else if(this.$route.query.category=='A'){//发展规划
          this.projectForm.title =this.$route.query.orgName + "关于要求对《"+this.$route.query.title+"》审核的请示";
        }else if(this.$route.query.planningRank=='A'&&this.$route.query.category!='A'){
          this.projectForm.title =this.$route.query.orgName + "关于要求对《"+this.$route.query.title+"》进行审核的函";
        }

      },
      goBack() {
        this.$router.go(-1);
      },
      // 获取步骤
      getListStep(){
        this.stepList = getStepList(this.category,this.planningRank,this.stepMap)
      },
      // 获取材料清单
      getMaterialList(category,planningRank){
        // 发展规划
        switch (category) {
          // 发展规划
          case 'A':
            this.materialData = materialDataList.otherMaterialData;
            break;
          // 专项规划
          case 'B':
            switch (planningRank) {
              // 重点
              case 'A':
                this.materialData = materialDataList.otherMaterialData;
                break;
              // 一般
              case 'B':
                this.materialData = materialDataList.otherMaterialData;
                break;
              // 备案
              case 'C':
                this.materialData = materialDataList.zxBaMaterialData;
                break
            }
            break;
          // 区域规划
          case 'C':
            this.materialData = materialDataList.otherMaterialData;
            break;
          // 空间规划
          case 'D':
            this.materialData = materialDataList.otherMaterialData;
            break
        }
      },
      // 获取规划详情信息
      getDetailData(){
        resultDetail(this.$route.params.id).then(response => {
          this.getresultDetail(response);
        })
      },
      // 修改标题
      changeHeaderTitle(category,planningRank){
        // 专项规划-》备案
        if(category == 'B' && planningRank == 'C'){
          this.headerData.title = '确认备案'
        }
      },
      uploadFlag(row,index){
        if(this.fileDialog[row.name]){
          if(this.fileTypeIds[row.name] && this.fileTypeIds[row.name].length>0){
            return true;
          }else{
            return false
          }
        }else{
          if(this.fileTypeIds[row.name] && this.fileTypeIds[row.name].length>0){
            return true;
          }else{
            return false
          }
        }
      },
      async getresultDetail(response){
        if(response.data.code == '0') {
          var records = response.data.data;
          this.category = records.category;
          this.planningRank = records.planningRank;
          this.regName = records.title;


          // 获取材料清单
          this.getMaterialList(records.category,records.planningRank);
          // 获取流程步骤
          this.getListStep();
          // 修改标题
          this.changeHeaderTitle(records.category,records.planningRank);
          // 备案类为'发布范围'
          if(records.planningRank == 'C'){
            this.openScopeText = '发布范围：'
          }
          if(records.fileId!="" && records.fileId !=null) {
            this.multiplefiles = [];
            this.multiplefiles = await this.getfileinfopagetemp(records);
          }
          this.pmuc = records.pmuc;
          this.getresultDetailDate(records)
        }
      },
      getfileinfopagetemp(records){
        return new Promise((resolve, reject) => {
          if(records.fileId!="" && records.fileId !=null){
            getfileinfopage(Object.assign({
              current: 1,
              size: 100,
              fileIds:records.fileId
            })).then(response => {
              var multiplefiles = response.data.data.records;
              resolve(multiplefiles);
            }).catch(
            )
          }
        })
      },
      regDetail(){
        this.regDetailDialogFlag = true
      },
      regDetailClose(){
        this.regDetailDialogFlag = false
      },
      // 获取详情信息
      getDetail(id){
        reviewDetail(id).then(async response => {
          this.projectForm = response.data.data;
          let records = response.data.data;
          await this.getReviewFileTypeFiles(records.reportFileIds,'报送文件');
          await this.getReviewFileTypeFiles(records.otherFileIds,'其他附件');
          await this.getReviewFileTypeFile(records.instruction,'编制说明');
          await this.getReviewFileTypeFile(records.txt,'规划文本');
          await this.getReviewFileTypeFile(records.connectOpinion,'衔接意见');
          await this.getReviewFileTypeFile(records.expertOpinion,'专家评审意见');
          await this.getReviewFileTypeFile(records.txtHalfOpen,'规划文本(部分公开)');
          if(this.fileTypeIds['其他附件'] && this.fileTypeIds['其他附件'].length>0)
            this.setMaterialData('其他附件');
          if(this.fileTypeIds['编制说明'] && this.fileTypeIds['编制说明'].length>0)
            this.setMaterialData('编制说明');
          if(this.fileTypeIds['规划文本'] && this.fileTypeIds['规划文本'].length>0)
            this.setMaterialData('规划文本');
          if(this.fileTypeIds['衔接意见'] && this.fileTypeIds['衔接意见'].length>0)
            this.setMaterialData('衔接意见');
          if(this.fileTypeIds['专家评审意见'] && this.fileTypeIds['专家评审意见'].length>0)
            this.setMaterialData('专家评审意见');
          if(this.fileTypeIds['规划文本(部分公开)'] && this.fileTypeIds['规划文本(部分公开)'].length>0)
            this.setMaterialData('规划文本(部分公开)')
        })
      },
      // 获取材料清单附件 单附件
      async getReviewFileTypeFile(id,name){
        if(!id || !name){
          return;
        }
        return new Promise((resolve, reject) => {
          getfileinfo(id).then(response => {
            var record = response.data.data;
            if(name == '报送文件'){
              this.defaultOtherFileIds.push({
                id:record.fileId,
                name:record.fileFullName
              });
              this.otherFileIds.push({
                id:record.fileId,
                name:record.fileFullName
              });
              resolve(this.defaultOtherFileIds);
              resolve(this.otherFileIds)
            }else{
              // 赋值前清零
              this.defaultFileTypeIds[name] = [];
              this.defaultFileTypeIds[name].push({
                id:record.fileId,
                name:record.fileFullName
              });
              this.fileTypeIds[name] = [];
              this.fileTypeIds[name].push({
                id:record.fileId,
                name:record.fileFullName
              });
              resolve(this.defaultFileTypeIds[name]);
              resolve(this.fileTypeIds[name])
            }
          })
        })
      },
      // 获取材料清单附件 多附件
      async getReviewFileTypeFiles(id,name){
        if(!id || !name){
          return;
        }
        var ids = '';
        for(var i in id){
          ids += id[i] + ','
        }
        if(ids){
          ids = ids.substring(0,ids.length-1)
        }
        return new Promise((resolve, reject) => {
          getfileinfopage({
            fileIds: ids
          }).then(response => {
            if (response.status == '200') {
              var record = response.data.data.records;
              for (let i in record) {
                if(name == '报送文件'){
                  this.defaultOtherFileIds.push({
                    id:record[i].fileId,
                    name:record[i].fileFullName
                  });
                  this.otherFileIds.push({
                    id:record[i].fileId,
                    name:record[i].fileFullName
                  });
                  resolve(this.defaultOtherFileIds);
                  resolve(this.otherFileIds)
                }else{
                  // 赋值前清零
                  this.defaultFileTypeIds[name] = [];
                  this.defaultFileTypeIds[name].push({
                    id: record[i].fileId,
                    name: record[i].fileFullName
                  });
                  this.fileTypeIds[name].push({
                    id: record[i].fileId,
                    name: record[i].fileFullName
                  });
                  resolve(this.defaultFileTypeIds[name]);
                  resolve(this.fileTypeIds[name])
                }
              }
            }
          })
        })
      },
      // 关闭附件弹窗
      handleClose(){
        this.fileDialog[this.fileType] = false
      },
      // 上传附件
      uploadFiles(row){
        //修改不允许重新上传附件
        if(!this.updateFlag || (row.name =='规划文本(部分公开)' && !this.fileTypeIds['规划文本(部分公开)'])){
          this.fileDialog[row.name] = true;
          this.fileType = row.name
        }
      },
      //请示件上传
      otherFileUpload(params){
        this.fileUpload(params,'3',this.otherFileMap)
      },
      // 请示件移除方法
      otherFileHandleRemove(file, fileList) {
        this.otherFileIds = this.otherFileIds.filter(item => item.uid != file.uid);
        // 修改时默认附件没有uid
        if(file.id){
          this.otherFileIds = this.otherFileIds.filter(item => item.id != file.id)
        }
      },
      // 请示件预览
      otherFileHandlePreview(file){
        var curFile = this.otherFileIds.filter(item => item.uid == file.uid);
        // 修改时默认附件没有uid
        if(!curFile){
          curFile = this.otherFileIds.filter(item => item.id == file.id)
        }
        var id = '';
        if(curFile && curFile.length>0){
          id = curFile[0].id
        }
        this.fileDownload(id,file.name)
      },
      // 表单附件验证
      validFileForm(projectForm){

      },
      // 新增审批发布并提交（）
      reviewSaveAndSubmit(){
        this.$refs.projectForm.validate(valid => {
          if (valid) {
            this.$confirm("确定审批发布并提交?", "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning"
            }).then(() => {
              this.projectForm.reportFileIds = this.getFileIds(this.otherFileIds);
              this.projectForm.otherFileIds = this.getFileIds(this.fileTypeIds['其他附件']);
              this.projectForm.connectOpinion = this.getFileId(this.fileTypeIds['衔接意见']);
              this.projectForm.expertOpinion = this.getFileId(this.fileTypeIds['专家评审意见']);
              this.projectForm.instruction = this.getFileId(this.fileTypeIds['编制说明']);
              this.projectForm.txt = this.getFileId(this.fileTypeIds['规划文本']);
              this.projectForm.txtHalfOpen = this.getFileId(this.fileTypeIds['规划文本(部分公开)']);
              this.validFileForm(this.projectForm);
              reviewSaveAndSubmit(this.projectForm).then(response => {
                if(response.data.code == 0){
                  this.$notify({
                    title: '成功',
                    message: '提交成功',
                    type: 'success',
                    duration: 2000
                  });
                  this.$router.go(-1);
                }
              })
            })
          }
        })
      },
      // 审批修改
      reviewUpdate(){
        this.$refs.projectForm.validate(valid => {
          if (valid) {
            this.$confirm("确定修改审批么?", "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning"
            }).then(() => {
              this.projectForm.reportFileIds = this.getFileIds(this.otherFileIds);
              this.projectForm.otherFileIds = this.getFileIds(this.fileTypeIds['其他附件']);
              this.projectForm.connectOpinion = this.getFileId(this.fileTypeIds['衔接意见']);
              this.projectForm.expertOpinion = this.getFileId(this.fileTypeIds['专家评审意见']);
              this.projectForm.instruction = this.getFileId(this.fileTypeIds['编制说明']);
              this.projectForm.txt = this.getFileId(this.fileTypeIds['规划文本']);
              this.projectForm.txtHalfOpen = this.getFileId(this.fileTypeIds['规划文本(部分公开)']);
              this.validFileForm(this.projectForm);
              reviewUpdate(this.reviewId,this.projectForm).then(response => {
                if(response.data.code == 0){
                  this.$notify({
                    title: '成功',
                    message: '修改成功',
                    type: 'success',
                    duration: 2000
                  });
                  this.$router.go(-1);
                }
              })
            })
          }
        })
      },
      // 审批修改并提交
      reviewUpdateAndSubmit(){
        this.$refs.projectForm.validate(valid => {
          if (valid) {
            this.$confirm("确定修改并提交审批么?", "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning"
            }).then(() => {
              this.projectForm.reportFileIds = this.getFileIds(this.otherFileIds);
              this.projectForm.otherFileIds = this.getFileIds(this.fileTypeIds['其他附件']);
              this.projectForm.connectOpinion = this.getFileId(this.fileTypeIds['衔接意见']);
              this.projectForm.expertOpinion = this.getFileId(this.fileTypeIds['专家评审意见']);
              this.projectForm.instruction = this.getFileId(this.fileTypeIds['编制说明']);
              this.projectForm.txt = this.getFileId(this.fileTypeIds['规划文本']);
              this.projectForm.txtHalfOpen = this.getFileId(this.fileTypeIds['规划文本(部分公开)']);
              this.validFileForm(this.projectForm);
              reviewUpdateAndSubmit(this.reviewId,this.projectForm).then(response => {
                if(response.data.code == 0){
                  this.$notify({
                    title: '成功',
                    message: '修改并提交成功',
                    type: 'success',
                    duration: 2000
                  });
                  this.$router.go(-1);
                }
              })
            })
          }
        })
      },
      successCallback(){
        this.setMaterialData(this.fileType)
      },
      setMaterialData(materialName){
        let self = this;
        this.materialData = this.materialData.map((v, index) => {
          if (v.name === materialName) {
            return {
              name: v.name,
              necessity: v.necessity,
              fileName:self.fileTypeIds[materialName][0].name,
              fileId:self.fileTypeIds[materialName][0].id
            }
          }
          return v;
        })
      },
      removeCallback(){
        this.removeMaterialData(this.fileType)
      },
      removeMaterialData(materialName){
        let self = this;
        this.materialData = this.materialData.map((v, index) => {
          if (v.name === materialName) {
            return {
              name: v.name,
              necessity: v.necessity
            }
          }
          return v;
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .relese-form-group {
    margin-top: 2rem;
  }
  .form-padding {
    padding-left: 50px;
  }
  .step-group {
    margin: 5rem 0;
    margin-bottom: 1px;
    margin-left:3rem;
  }
  /deep/.avue-crud__menu{
    display: none
  }
</style>
